﻿<?php

class StatisticController extends Controller
{
	public function filters()
	{
		return array(
			'accessControl', // perform access control for CRUD operations
		);
	}

	public function accessRules(){
	    return array(
	        array('allow', // allow authenticated users to access all actions
				'users'=>array('@'),
			),
	        array('deny', // deny anything else
	              'users'=>array('*'),
	        ),
	    );
	}

    public function actionIndex()
    {   
            $this -> render('index',array(	

            ));
    }
	
	// Thống kê số lượng site new và scam hàng ngày
	public function actionNumberDaily()
    {
        $this -> render('numberDaily',array(	

		));
    } 
	
    public function actionGetNumberDaily()
    {
        $model = new Statistic();
        $result = $model -> getSiteNumberDaily();
		
        echo json_encode($result);
    } 
	
	// Thống kê theo lifespan
	public function actionLifespan()
    {
        $this -> render('lifespan',array(	

		));
    } 
	
	public function actionGetLifespan()
    {
        $model = new Statistic();
		$result = $model -> getSiteNumberDaily();
		
		echo json_encode($result);
    } 
	
    public function actionStSiteNumberDaily()
    {
        $model = new Statistic();		
		
		if($model -> stNewAndScamSiteDaily() > 0)
		{
			echo json_encode(array("status" => 'success'));
		}
		else
		{
			echo json_encode(array("status" => 'failure'));
		}
    }    
	
	public function actionStLifespan()
    {
        $model = new Statistic();		
		
		if($model -> stLifespanOfHyip())
		{
			echo json_encode(array("status" => 'success'));
		}
		else
		{
			echo json_encode(array("status" => 'failure'));
		}
    }   
}